package com.hiv.client.model.weixin;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_11.shtml
 * 退款通知
 *
 * https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_3_5.shtml todo
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class WeixinRefundNotifyReq implements Serializable {
  /** 通知的唯一ID */
  private String id;
  /** 通知创建时间 */
  private String create_time;
  /** 通知类型：支付成功通知的类型为TRANSACTION.SUCCESS*/
  private String event_type;
  /** 通知数据类型：支付成功通知为encrypt-resource */
  private String resource_type;
  /** 通知数据 */
  private Resource resource;
  /** 回调摘要 */
  private String summary;

  @Data
  @NoArgsConstructor
  @AllArgsConstructor
  public static class Resource implements Serializable {
    /** 加密算法类型: 对开启结果数据进行加密的加密算法，目前只支持AEAD_AES_256_GCM */
    private String algorithm;
    /** 数据密文: Base64编码后的开启/停用结果数据密文 */
    private String ciphertext;
    /** 附加数据 */
    private String associated_data;
    /** 原始类型:原始回调类型，为transaction */
    private String original_type;
    /** 随机串: 加密使用的随机串 */
    private String nonce;
  }

  /**
   {
   "mchid": "1900000100",
   "transaction_id": "1008450740201411110005820873",
   "out_trade_no": "20150806125346",
   "refund_id": "50200207182018070300011301001",
   "out_refund_no": "7752501201407033233368018",
   "refund_status": "SUCCESS",
   "success_time": "2018-06-08T10:34:56+08:00",
   "user_received_account": "招商银行信用卡0403",
   "amount" : {
   "total": 999,
   "refund": 999,
   "payer_total": 999,
   "payer_refund": 999
   }
   }
   */
  @Data
  @NoArgsConstructor
  @AllArgsConstructor
  public static class DecryptResource implements Serializable {
    /** 商户号 */
    private String mchid;
    /** 商户订单号：示例值： 1217752501201407033233368018 */
    private String out_trade_no;
    /** 微信支付订单号 */
    private String transaction_id;
    /** 商户退款单号：示例值： 1217752501201407033233368018 */
    private String out_refund_no;
    /** 微信支付退款单号：示例值： 1217752501201407033233368018 */
    private String refund_id;
    /** 退款状态：示例值：SUCCESS | CLOSED | ABNORMAL */
    private String refund_status;
    /** 退款成功时间：示例值：2018-06-08T10:34:56+08:00 */
    private String success_time;
    /** 退款入账账户：示例值：招商银行信用卡0403 */
    private String user_received_account;
    /** 金额信息 */
    private Amount amount;
  }
  @Data
  @NoArgsConstructor
  @AllArgsConstructor
  public static class Amount implements Serializable {
    /** 订单金额 */
    private long total;
    /** 退款金额 */
    private long refund;
    /** 用户支付金额 */
    private long payer_total;
    /** 用户退款金额 */
    private long payer_refund;
  }
}
